{extend name='main'}

{block name="button"}

{if auth("add_users")}
<button data-modal='{:url("add_users")}' data-title="添加会员" class='layui-btn'>添加会员</button>
{/if}

{/block}

{block name="content"}

<div class="think-box-shadow">
    {include file='users/index_search'}
    <table class="layui-table" lay-filter="tab" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th lay-data="{field:'id',width:80}" class='text-left nowrap'>ID</th>
            <!--<th lay-data="{field:'invite_code'}" class='text-left nowrap'>邀请码</th>-->
            <!--<th lay-data="{field:'create_time',width:200}" class='text-left nowrap'>注册时间</th>-->
            <th lay-data="{field:'phone'}" class='text-left nowrap'>手机号码</th>
            <th lay-data="{field:'username'}" class='text-left nowrap'>会员账号</th>
            <th lay-data="{field:'group'}" class='text-left nowrap'>会员分组</th>
            <th lay-data="{field:'level'}" class='text-left nowrap'>会员等级</th>
            <!--<th lay-data="{field:'day_max_o'}" class='text-left nowrap'>接单上线</th>-->
            <!--<th lay-data="{field:'day_o'}" class='text-left nowrap'>已接单</th>-->
            <th lay-data="{field:'balance'}" class='text-left nowrap'>账户余额</th>
            <!--<th lay-data="{field:'freeze'}" class='text-left nowrap'>冻结资金</th>-->
            <!--<th lay-data="{field:'pid'}" class='text-left nowrap'>上级账号</th>-->
            
            
            
            <th lay-data="{field:'edit',width:280,fixed: 'right'}" class='text-left nowrap'>操作</th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='text-left nowrap'>{$vo.id}</td>
            <!--<td class='text-left nowrap'>{$vo.invite_code}</td>-->
            <!--<td class='text-left nowrap'>{$vo.create_time|format_datetime}</td>-->
            <td class='text-left nowrap'>{$vo.phone}</td>
            <td class='text-left nowrap'>{$vo.username}</td>
            <td class='text-left nowrap'>{$vo.group|get_group}</td>
            <!--<td class='text-left nowrap'>{$vo.level}级</td>-->
            {switch vo.level}
                {case 0}<td class='text-left nowrap'>VIP0{/case}
                {case 7}<td class='text-left nowrap'>VIP0{/case}
                {case 1}<td class='text-left nowrap'>VIP1{/case}
                {case 2}<td class='text-left nowrap'>VIP2{/case}
                {case 3}<td class='text-left nowrap'>VIP3{/case}
                {case 4}<td class='text-left nowrap'>VIP4{/case}
                {case 5}<td class='text-left nowrap'>VIP5{/case}
                {case 6}<td class='text-left nowrap'>VIP6{/case}
                {case 8}<td class='text-left nowrap'>超级VIP{/case}
            {/switch}
            <!--<td class='text-left nowrap'>{$vo.day_max_o}</td>-->
            <!--<td class='text-left nowrap'>{$vo.day_o}</td>-->
            <td class='text-left nowrap'>{$vo.balance}</td>
            <!--<td class='text-left nowrap'>{$vo.freeze}</td>-->
            <!--<td class='text-left nowrap'>{$vo.pid|get_pid_name}</td>-->
            
            
            
        
            
            <td class='text-left nowrap'>
                {if auth("edit_users")}
                <!--<a class="layui-btn layui-btn-xs layui-bg-blue" role="button" onClick="recharge({$vo.id})">充值</a>-->
                <a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑菜单" data-modal='{:url("admin/users/recharges")}?id={$vo.id}'>人工余额操作</a>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    <script>
        function recharge(id){
            layer.prompt({title: '输请输入充值金额', formType: 3}, function(money, index){
                layer.close(index);
                $.ajax({
                    url: "{:Url('recharge')}",
                    type: "post",
                    traditional: true,
                    data: {id:id,money:money},
                    success: function (e) {
                        layer.closeAll('loading');
                        if (e.code === 1){
                            layer.msg(e.msg, {
                                time: 2000,
                                end: function () {
                                    location.reload();
                                }
                            });
                        }else {
                            layer.msg(e.msg, function(){});
                            return false;
                        }
                    },
                });
            });
        }
    </script>
    <script>
        var table = layui.table;
        //转换静态表格
        var limit = Number('{$Think.get.limit}');
        if(limit==0) limit=20;
        table.init('tab', {
            cellMinWidth:120,
            skin: 'line,row',
            even: false,
            size: 'sm ',
            limit: limit
        });
    </script>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pages|raw|default=''}{/empty}
</div>
{/block}
